package ms.maplestory.boot.enums;

import ms.maplestory.boot.util.Util;

import java.util.Arrays;

/**
 * 职业类型
 */
public enum JobType {

    Beginner(0, "新手", 0),
    Warrior(100, "战士", 0),
    Fighter(110, "剑客", 0),
    Crusader(111, "勇士", 0),
    Hero(112, "英雄", 0),
    Page(120, "准骑士", 0),
    WhiteKnight(121, "骑士", 0),
    Paladin(122, "圣骑士", 0),
    Spearman(130, "枪战士", 0),
    DragonKnight(131, "龙骑士", 0),
    DarkKnight(132, "黑骑士", 0),
    magician(200, "魔法师", 0),
    FpWizard(210, "法师(火,毒)", 0),
    FpMage(211, "巫师(火,毒)", 0),
    FpArchMage(212, "魔导师(火,毒)", 0),
    IlWizard(220, "法师(冰,雷)", 0),
    IlMage(221, "巫师(冰,雷)", 0),
    IlArchMage(222, "魔导师(冰,雷)", 0),
    Cleric(230, "牧师", 0),
    Priest(231, "祭司", 0),
    Bishop(232, "主教", 0),
    Bowman(300, "弓箭手", 0),
    Hunter(310, "猎手", 0),
    Ranger(311, "射手", 0),
    BowMaster(312, "神射手", 0),
    Crossbowman(320, "弩弓手", 0),
    Sniper(321, "游侠", 0),
    Marksman(322, "箭神", 0),
    Thief(400, "飞侠", 0),
    Assassin(410, "刺客", 0),
    Hermit(411, "无影人", 0),
    NightLord(412, "隐士", 0),
    Bandit(420, "侠客", 0),
    ChiefBandit(421, "独行客", 0),
    ShaDower(422, "侠盗", 0),
    Pirate(500, "海盗", 0),
    Brawler(510, "拳手", 0),
    Marauder(511, "斗士", 0),
    Buccaneer(512, "冲锋队长", 0),
    Gunslinger(520, "火枪手", 0),
    Outlaw(521, "大副", 0),
    Corsair(522, "船长", 0),

    Noblesse(1000, "初心者", 1000),
    DawnWarrior1(1100, "魂骑士", 1000),
    DawnWarrior2(1110, "魂骑士", 1000),
    DawnWarrior3(1111, "魂骑士", 1000),
    DawnWarrior4(1112, "魂骑士", 1000),
    BlazeWizard1(1200, "炎术士", 1000),
    BlazeWizard2(1210, "炎术士", 1000),
    BlazeWizard3(1211, "炎术士", 1000),
    BlazeWizard4(1212, "炎术士", 1000),
    WindArcher1(1300, "风灵使者", 1000),
    WindArcher2(1310, "风灵使者", 1000),
    WindArcher3(1311, "风灵使者", 1000),
    WindArcher4(1312, "风灵使者", 1000),
    NightWalker1(1400, "夜行者", 1000),
    NightWalker2(1410, "夜行者", 1000),
    NightWalker3(1411, "夜行者", 1000),
    NightWalker4(1412, "夜行者", 1000),
    ThunderBreaker1(1500, "奇袭者", 1000),
    ThunderBreaker2(1510, "奇袭者", 1000),
    ThunderBreaker3(1511, "奇袭者", 1000),
    ThunderBreaker4(1512, "奇袭者", 1000),

    Legend(2000, "战童", 2000),
    Evan(2001, "龙神", 2001),
    Aran1(2100, "战神", 2000),
    Aran2(2110, "战神", 2000),
    Aran3(2111, "战神", 2000),
    Aran4(2112, "战神", 2000),
    Evan1(2200, "龙神", 2001),
    Evan2(2210, "龙神", 2001),
    Evan3(2211, "龙神", 2001),
    Evan4(2212, "龙神", 2001),
    Evan5(2213, "龙神", 2001),
    Evan6(2214, "龙神", 2001),
    Evan7(2215, "龙神", 2001),
    Evan8(2216, "龙神", 2001),
    Evan9(2217, "龙神", 2001),
    Evan10(2218, "龙神", 2001),
    BladeRecruit(430, "见习刀客", 0),
    BladeAcolyte(431, "双刀客", 0),
    BladeSpecialist(432, "双刀侠", 0),
    BladeLord(433, "血刀", 0),
    BladeMaster(434, "暗影双刀", 0),

    Citizen(3000, "预备兵", 3000),
    BattleMage1(3200, "幻灵斗师", 3000),
    BattleMage2(3210, "幻灵斗师", 3000),
    BattleMage3(3211, "幻灵斗师", 3000),
    BattleMage4(3212, "幻灵斗师", 3000),
    WildHunter1(3300, "弩豹游侠", 3000),
    WildHunter2(3310, "弩豹游侠", 3000),
    WildHunter3(3311, "弩豹游侠", 3000),
    WildHunter4(3312, "弩豹游侠", 3000),
    Mechanic1(3500, "机械师", 3000),
    Mechanic2(3510, "机械师", 3000),
    Mechanic3(3511, "机械师", 3000),
    Mechanic4(3512, "机械师", 3000),

    Manager(800, "巡检员", 0),
    Gm(900, "管理员", 0),
    SuperGm(910, "超级管理员", 0);

    private int id;
    private String name;
    private int beginnerId;

    JobType(int id, String name, int beginnerId) {
        this.id = id;
        this.name = name;
        this.beginnerId = beginnerId;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public int getBeginnerId() {
        return beginnerId;
    }

    public static JobType getJobById(int id) {
        return Util.findWithPred(values(), job -> job.getId() == id);
    }

    public enum LoginJob {

        Resistance(0, JobFlag.Enabled, JobType.Citizen),
        Explorer(1, JobFlag.Enabled, JobType.Beginner),
        Cygnus(2, JobFlag.Enabled, JobType.Noblesse),
        Aran(3, JobFlag.Enabled, JobType.Legend),
        Evan(4, JobFlag.Enabled, JobType.Evan);

        private final int jobType, flag;
        private JobType beginJob;

        LoginJob(int jobType, JobFlag flag, JobType beginJob) {
            this.jobType = jobType;
            this.flag = flag.getFlag();
            this.beginJob = beginJob;
        }

        public int getJobType() {
            return jobType;
        }

        public int getFlag() {
            return flag;
        }

        public JobType getBeginJob() {
            return beginJob;
        }

        public enum JobFlag {

            Disabled(0),
            Enabled(1);

            private final int flag;

            JobFlag(int flag) {
                this.flag = flag;
            }

            public int getFlag() {
                return flag;
            }
        }

        public static LoginJob getLoginJobById(int id) {
            return Arrays.stream(LoginJob.values()).filter(j -> j.getJobType() == id).findFirst().orElse(null);
        }
    }
}


